<template>
  <div class="list">
    <van-nav-bar
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="select">
      
      <el-input
        placeholder="报表天数"
        type="tel"
        v-model="value"
        clearable>
      </el-input>
      <van-button type="info" size="small" @click="checkChange">查询</van-button>
    </div>
    <el-table
      :data="tableData"
      border
      :cell-style="{'text-align':'center','padding':'0'}"
      :header-cell-style="{
        'background-color': '#fff',
        'color':'#555',
        'text-align':'center'
      }"
      style="width: 100%">
      <el-table-column
        prop="tongjiDay"
        label="日期"
        >
      </el-table-column>
      <el-table-column
        prop="totalUserCount"
        label="总注册">
      </el-table-column>
      <el-table-column
        prop="totalDAU"
        label="日活">
      </el-table-column>
      <el-table-column
        prop="totalUserCountCurrentDay"
        label="新增">
      </el-table-column>
      <el-table-column
        prop="totalInvitationUserCount"
        label="收徒用户数">
      </el-table-column>
      <el-table-column
        prop="totalBeInvitatedUserCount"
        label="收徒数">
      </el-table-column>
      <el-table-column
        prop="totalPublishHongbao"
        label="发红包数">
      </el-table-column>
      <el-table-column
        prop="totalTakeHongbao"
        label="领红包数">
      </el-table-column>
      <el-table-column
        prop="totalTakeHongbaoMoney"
        label="红包金额">
      </el-table-column>
      <el-table-column
        prop="totalApplyWithdrawUsers"
        label="提现用户数">
      </el-table-column>

      <el-table-column
        prop="totalApplyWithdrawAmountFinished"
        label="提现金额">
      </el-table-column>
      <el-table-column
        prop="totalZhuanfaUsers"
        label="转发用户数">
      </el-table-column>

      <el-table-column
        prop="totalZhuanfaCount"
        label="转发IP">
      </el-table-column>
      <el-table-column
        prop="totalZhuanfaMoney"
        label="结算金额">
      </el-table-column>           
      
    </el-table>
    
  </div>
</template>

<script>
import { getCookie,setCookie } from "./until/index";
function init(){
  this.$toast.loading({
    message:'加载中...'
  })
  
  this.$ajax.get("rptMGetYunyingShuju.ashx?uid="+getCookie("userid") +"&token=" +getCookie("token")+'&diffDay=' + this.value)
      .then(res => {
        if (res.data.code === "200") {
          var data = res.data.data            
          this.tableData = data.reportList;
          this.$toast.clear()
        } else {

          this.$message.error(res.data.msg );
        }
      })
      .catch(error => {
        console.log(error);
      });
}
export default {
  data () {
    return {
      title:'运营数据',
      value:'',
      tableData:[]
    }
  },
  created () {
    if(!getCookie("userid") || !getCookie("token")){
      setCookie('token','',-1)
      setCookie('userid','',-1)
      window.location.href='/'
    }
    
    init.call(this)
  },
  methods: {
    onClickLeft(){
      this.$router.go(-1)
    },
    checkChange(){
      if(this.value > 30){
        this.$message.error('所填天数需小于30' );
        return
      }
      init.call(this)
    }
  }
}
</script>
<style scoped>
.select{margin: 10px;display: flex;justify-content: center;align-items: center;width: 400px}
.el-input{margin:0 5px}

</style>
  